﻿using System.ComponentModel;
using System.IO;
using Rio.Framework.WCFService.RioWcfServices;

namespace Rio.Framework.Pages
{
    public class ImageRioSearch : ImageRio, INotifyPropertyChanged
    {
        #region Attributs

        private bool _IsCutedOrCopied;
        private WorkflowState _workflowState = WorkflowState.None;

        #endregion

        public long Identifier { get; set; }
        public string OriginalName { get; set; }
        public string ImageName { get; set; }
        public string RelativePath { get; set; }
        public bool IsFullSearch { get; set; }

        public WorkflowState WorkflowState
        {
            get { return _workflowState; }
            set
            {
                _workflowState = value;
                OnNotifyPropertyChanged("WorkflowState");
            }
        }

        public bool IsCutedOrCopied
        {
            get { return _IsCutedOrCopied; }
            set
            {
                _IsCutedOrCopied = value;
                OnNotifyPropertyChanged("IsCutedOrCopied");
            }
        }

        public string ImageFullPath
        {
            get
            {
                return Path.Combine(RelativePath, ImageName);
            }
            set { }
        }

        public string ThumbnailFullPath
        {
            get
            {
                return Path.Combine(RelativePath, Name);
            }
            set { }
        }

        private byte[] m_oImg;

        public new byte[] Img
        {
            get { return m_oImg; }
            set
            {
                m_oImg = value;
                OnNotifyPropertyChanged("Img");
            }
        }

        public ImageRioSearch()
        {
            IsCutedOrCopied = false;
        }

        public ImageRioSearch(long P_lIdentifier, string P_szName, byte[] P_bmImg, long p_iFileSize, string p_sOriginalName, string p_sImageName, string p_sRelativePath)
            : this()
        {
            Identifier = P_lIdentifier;
            Name = P_szName;
            Img = P_bmImg;
            ImageSize = p_iFileSize;
            OriginalName = p_sOriginalName;
            ImageName = p_sImageName;
            RelativePath = p_sRelativePath;
        }

        public ImageRioSearch(long P_lIdentifier, string P_szName, byte[] P_bmImg, long p_iFileSize, string p_sOriginalName, string p_sImageName, string p_sRelativePath, int p_iNumberPages)
            : this(P_lIdentifier, P_szName, P_bmImg, p_iFileSize, p_sOriginalName, p_sImageName, p_sRelativePath)
        {
            NumberPages = p_iNumberPages;
        }

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;
        private void OnNotifyPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        #endregion
    }
}
